package com.wang.mandkey.activity;

import java.util.ArrayList;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.LinearLayout;
import android.widget.ListView;

import com.wang.mandkey.R;
import com.wang.mandkey.adapter.BoxAdapter;
import com.waps.AdView;

public class BoxActivity extends BaseActivity {

	private ListView mListView;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		initView();
	}

	private void initView() {
		setContentView(R.layout.box);
		mListView = (ListView) findViewById(R.id.listViewBoxs);
		ArrayList<String> datas = new ArrayList<String>();

		datas.add("二维码,条码扫描,最方便的扫描器!");
		datas.add("达人广场--->达人必备!");
		BoxAdapter boxAdater = new BoxAdapter(datas, BoxActivity.this);
		mListView.setAdapter(boxAdater);
		mListView.setOnItemClickListener(new OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {
				if (0 == position) {
					// qr扫描
					Intent i = new Intent();
					i.setClass(BoxActivity.this, ScanActivity.class);
					startActivity(i);
				}
				if (1 == position) {
					Intent i = new Intent();
					i.setClass(BoxActivity.this, RecommandAPpListActivity.class);
					startActivity(i);
				}
			}
		});
		
		LinearLayout container = (LinearLayout) findViewById(R.id.AdLinearLayout);
		new AdView(this, container).DisplayAd();
	}

	@Override
	public void onBackPressed() {
		super.onBackPressed();
		finish();
		return;
	}
}
